﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;
using System.Text;

namespace WebSite.cn
{
    public partial class bottom : System.Web.UI.UserControl
    {
        public string linkstr = "";

        public StringBuilder sbFooterHtml = new StringBuilder(); 

        // Methods
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {

                this.BindBottomMenu();
                }
            }

        void BindBottomMenu()
        {
            string str2 = "select classid,classlink,classname from DB_Class where parentid=0 and visible=1 and classname<>'' and (classpcs='底部' or classpcs='顶部和底部')  order by classorder";
            DataTable table2 = SQLAccess.GreatDs(str2).Tables[0];

            DataTable tableSub;

            foreach (DataRow dr in table2.Rows)
            {
                sbFooterHtml.AppendFormat("<dl><dt>{0}</dt>"
                                           , dr["classname"].ToString()
                                           );
                tableSub = SQLAccess.GreatDs(string.Format("select classid,classlink,classname from DB_Class where parentid={0} and visible=1 and classname<>''    order by classorder", dr["classid"].ToString())).Tables[0];
                if (tableSub != null && tableSub.Rows.Count > 0)
                {
                    foreach (DataRow drSub in tableSub.Rows)
                    {
                        sbFooterHtml.AppendFormat("<dd><a href=\"{0}\">{1}</a></dd>"
                            , drSub["classlink"].ToString() == "" ? "/cn/content.aspx?cid=" + drSub["classid"].ToString() : drSub["classlink"].ToString()
                                                   , drSub["classname"].ToString()
                                                   );

                    }
                }
                sbFooterHtml.Append("</dl>");
            }
        }

        void BindLink()
        {
            //string sql = "select * from DB_Link where visible=1 and languages=1 order by linkorder";
            //DataTable table = SQLAccess.GreatDs(sql).Tables[0];
            //if (table.Rows.Count > 0)
            //{
            //    foreach (DataRow row in table.Rows)
            //    {
            //        if (row["linkfile"].ToString() != "")
            //        {
            //            string linkstr = this.linkstr;
            //            this.linkstr = linkstr + "<a href='" + row["linkurl"].ToString() + "' target='_blank'><img src='/uploadfile/link/" + row["linkfile"].ToString() + "' border='0' /></a>  ";
            //        }
            //        else
            //        {
            //            string str4 = this.linkstr;
            //            this.linkstr = str4 + "<a href='" + row["linkurl"].ToString() + "' target='_blank'>" + row["linkname"].ToString() + "</a>  ";
            //        }
            //    }
            //}
            
        }



    }
}